home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / filesy~1 / mfs609s.zoo / fsck / fs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-25  |  5.0 KB  |  140 lines

  1. /* This is a barebones file that defines the structures of the fs
  2.  * along with a few constants
  3.  */
  4.  
  5. #ifndef NULL
  6. #define NULL 0L
  7. #endif
  8.  
  9.  
  10. #ifdef V1
  11. #define d_inode d_inode1
  12. #define NINDIR 512              /* Zones per indirection block */
  13. #define NDIR   7                /* Direct zones in inode */
  14. #define MAGIC SUPER_V1          /* Super block magic number */
  15. #define MAGIC_ALT SUPER_V2
  16. #define NR_ZONE    NR_ZONE1
  17. typedef unsigned short zone_nr;
  18. #define do_fsck do_fsck1
  19. #define FS_TYPE "V1"
  20. #else
  21.  
  22. #ifdef V2
  23. #define d_inode d_inode2
  24. #define NINDIR 256
  25. #define NDIR    7
  26. #define MAGIC SUPER_V2
  27. #define MAGIC_ALT SUPER_V1
  28. #define NR_ZONE NR_ZONE2
  29. typedef long zone_nr;
  30. #define do_fsck do_fsck2
  31. #define FS_TYPE "V2"
  32.  
  33. #endif
  34. #endif
  35.  
  36. #define IPB    (BLOCKSIZE/sizeof(d_inode))    /* Inodes per block */
  37. #define DSIZE (sizeof(dir_struct))        /* Directory entry size */
  38. #define DPB (BLOCKSIZE/DSIZE)            /* Entries per block */
  39.  
  40.  
  41. /* Useful macro , is non zero only if 'x' is not a power of two */
  42.  
  43. #define NPOW2(x) ( ( (x) & (x-1) )!=0)
  44.  
  45. /* Macro to determine maximum filename length for a given increment */
  46.  
  47. #define MMAX_FNAME(x) ( ( (x)<<4 ) -2)
  48.  
  49. /* Absolute maximum filename length */
  50.  
  51. #define MNAME_MAX MMAX_FNAME(MAX_INCREMENT)
  52.  
  53. #define BLOCKSIZE    1024l    /* # bytes in a disk block */
  54.  
  55. /* Flag bits for i_mode in the inode. */
  56.  
  57. #define I_SYMLINK    0160000 /* symbolic link (not standard minix) */
  58.  
  59. #define I_TYPE        0170000    /* this field gives inode type */
  60. #define I_REGULAR    0100000    /* regular file, not dir or special */
  61. #define I_BLOCK_SPECIAL 0060000    /* block special file */
  62. #define I_DIRECTORY    0040000    /* file is a directory */
  63. #define I_CHAR_SPECIAL    0020000    /* character special file */
  64. #define I_NAMED_PIPE    0010000 /* named pipe (FIFO) */
  65. #define I_SET_UID_BIT    0004000    /* set effective uid_t on exec */
  66. #define I_SET_GID_BIT    0002000    /* set effective gid_t on exec */
  67. #define I_STICKY    0001000 /* sticky bit */
  68. #define ALL_MODES    0007777    /* all bits for user, group and others */
  69. #define RWX_MODES    0000777    /* mode bits for RWX only */
  70. #define R_BIT        0000004    /* Rwx protection bit */
  71. #define W_BIT        0000002    /* rWx protection bit */
  72. #define X_BIT        0000001    /* rwX protection bit */
  73. #define I_NOT_ALLOC    0000000    /* this inode is free */
  74.  
  75. /* Miscellaneous constants */
  76. #define SUPER_V1   0x137F    /* magic number contained in super-block */
  77. #define SUPER_V2   0x2468    /* v2 magic number */
  78.  
  79. #define NR_ZONE1 9
  80. #define NR_ZONE2 10
  81.  
  82. /* Macros for zone counts */
  83.  
  84. #define    NO_IND(x)    (((x)-NDIR+NINDIR-1)/NINDIR)
  85. #define NO_DBL(x)    ( (x > NDIR + NINDIR) ? 1 : 0)
  86.  
  87. #define ROOT_INODE  1    /* inode number for root directory */
  88.  
  89.  
  90. typedef struct    {
  91.   unsigned short s_ninodes;        /* # usable inodes on the minor device */
  92.   unsigned short s_nzones;        /* total device size, including bit maps etc */
  93.   unsigned short s_imap_blks;        /* # of blocks used by inode bit map */
  94.   unsigned short s_zmap_blks;        /* # of blocks used by zone bit map */
  95.   unsigned short s_firstdatazn;    /* number of first data zone */
  96.   short int s_log_zsize;    /* log2 of blocks/zone */
  97.   long  s_max_size;        /* maximum file size on this device */
  98.   short s_magic;        /* magic number to recognize super-blocks */
  99.   short pad;            /* padding */
  100.   long s_zones;            /* long version of s_nzones for v2 */
  101. } super_block;
  102.  
  103. /* This is what a directory entry on the disk looks like. Note: we can use
  104.  * a dirty trick to use this same structure for large filenames > 14 chars
  105.  * the idea is to use only a fraction of the total entries , so that if
  106.  * say the filename size is 30 we just use entries 0,2,4,6,8 etc. d_name
  107.  * then occupies all of the next entry. This forces the max filename size
  108.  * to be 2 less than a power of two (and certainly less than 1022), normally
  109.  * 30 should be more than adequate to cover every filename you'll ever see.
  110.  * 62 is for paranoids , but remember the path name limit of 128 characters.
  111.  */
  112.  
  113. typedef struct {        /* directory entry */
  114.   unsigned short d_inum;    /* inode number */
  115.   char d_name[14];        /* character string */
  116. } dir_struct;
  117.  
  118. typedef struct {        /* disk inode. */
  119.   unsigned short i_mode;        /* file type, protection, etc. */
  120.   unsigned short i_uid;            /* user id of the file's owner */
  121.   long i_size;            /* current file size in bytes */
  122.   long i_mtime;        /* when was file data last changed */
  123.   unsigned char i_gid;            /* group number */
  124.   unsigned char i_nlinks;        /* how many links to this file */
  125.   unsigned short i_zone[NR_ZONE1];    /* block nums for direct, ind, and dbl ind */
  126. } d_inode1;
  127.  
  128. typedef struct {        /* V2.x disk inode */
  129.   unsigned short i_mode;        /* file type, protection, etc. */
  130.   unsigned short i_nlinks;        /* how many links to this file. HACK! */
  131.   unsigned short i_uid;            /* user id of the file's owner. */
  132.   unsigned short i_gid;            /* group number HACK! */
  133.   long i_size;        /* current file size in bytes */
  134.   long i_atime;        /* when was file data last accessed */
  135.   long i_mtime;        /* when was file data last changed */
  136.   long i_ctime;        /* when was inode data last changed */
  137.   long i_zone[NR_ZONE2];    /* block nums for direct, ind, and dbl ind */
  138. } d_inode2;
  139.  
  140.